“Please wait while Bamboo sets up your instance” taking for ever on Mac

I am trying to install and configure Bamboo on mac. I have installed it and now at the stage of running the setup wizard. After giving the license and selecting “Express installation”, now am stuck at “Please wait while Bamboo sets up your instance” page. It’s taking forever. What could be causing this?

Updating the errors I found in the logs:

2019-06-14 11:32:06,547 WARN [setupDefaultGeneralBackgroundThread]         [GenericTypeAwarePropertyDescriptor] Invalid JavaBean property          'mappingResources' being accessed! Ambiguous write methods found next to actually used [public void   bucket.core.persistence.hibernate.ConfigurableLocalSessionFactoryBean.setMappingResources(bucket.core.persistence.hibernate.MappingResources)]: [public void org.springframework.orm.hibernate5.LocalSessionFactoryBean.setMappingResources(java.lang.String[])] 2019-06-14 11:32:06,902 INFO [http-nio-8085-exec-13] [AccessLogFilter] 0:0:0:0:0:0:0:1 POST http://localhost:8085/setup/setupDefaultGeneral.action 422910kb 2019-06-14 11:32:06,977 WARN [setupDefaultGeneralBackgroundThread] [XmlWebApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reloadableBeanFactories' defined in class path resource [applicationContextPlugin.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2019-06-14 11:32:06,979 ERROR [setupDefaultGeneralBackgroundThread] [ContextLoader] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reloadableBeanFactories' defined in class path resource [applicationContextPlugin.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:490)     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$  doGetBean$  0(AbstractBeanFactory.java:317)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)     at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:236)     at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:708)     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)     at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)     at com.atlassian.config.spring.BootstrappedContainerContext.refresh(BootstrappedContainerContext.java:22)     at com.atlassian.bamboo.setup.DefaultHibernateConfigurator.refreshSpringContextAndCreateDatabase(DefaultHibernateConfigurator.java:120)     at com.atlassian.bamboo.setup.DefaultHibernateConfigurator.configureDatabase(DefaultHibernateConfigurator.java:63)     at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.bootstrapDatabase(DefaultAtlassianBootstrapManager.java:258)     at com.atlassian.bamboo.ww2.actions.setup.SetupUtilityBean.setupStandardDatabase(SetupUtilityBean.java:187)     at com.atlassian.bamboo.ww2.actions.setup.SetupUtilityBean.setupEmbeddedDatabase(SetupUtilityBean.java:178)     at com.atlassian.bamboo.ww2.actions.setup.SetupDefaultsAction$  SetupDefaultDatabase.call(SetupDefaultsAction.java:86)     at com.atlassian.bamboo.ww2.actions.setup.SetupDefaultsAction$  SetupDefaultGeneral.call(SetupDefaultsAction.java:69)     at com.atlassian.bamboo.ww2.actions.setup.SetupDefaultsAction$  SetupDefaultGeneral.call(SetupDefaultsAction.java:43)     at com.atlassian.bamboo.ww2.actions.setup.SetupInvoker.execute(SetupInvoker.java:15)     at com.atlassian.bamboo.ww2.actions.setup.SetupDefaultsAction.general(SetupDefaultsAction.java:40)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.base/java.lang.reflect.Method.invoke(Method.java:566)     at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:899)     at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1544)     at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)     at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:98)     at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:90)     at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1620)     at ognl.ASTMethod.getValueBody(ASTMethod.java:91)     at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)     at ognl.SimpleNode.getValue(SimpleNode.java:258)     at ognl.Ognl.getValue(Ognl.java:470)     at ognl.Ognl.getValue(Ognl.java:434)     at com.opensymphony.xwork2.ognl.OgnlUtil$  3.execute(OgnlUtil.java:401)     at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecuteMethod(OgnlUtil.java:453)     at com.opensymphony.xwork2.ognl.OgnlUtil.callMethod(OgnlUtil.java:399)     at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:438)     at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:293)     at org.apache.struts2.interceptor.BackgroundProcess$  1.run(BackgroundProcess.java:55)     at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1597)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1349)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$  doGetBean$  0(AbstractBeanFactory.java:317)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)     at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91)     at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:109)     at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92)     at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101)     at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:254)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1060)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1033)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484)     ... 42 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:490)     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$  doGetBean$  0(AbstractBeanFactory.java:317)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:367)     ... 59 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1597)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1349)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$  doGetBean$  0(AbstractBeanFactory.java:317)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)     at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91)     at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:109)     at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92)     at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101)     at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:254)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1060)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1033)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484)     ... 64 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1597)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1349) mac bamboo 

Why is in a c# test class the Selenium Wait no longer timing out

I have a small extension method to find an element using the WebDriverWait

public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds)     {         if (timeoutInSeconds > 0)         {             var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));             return wait.Until(drv => drv.FindElement(by));         }          return driver.FindElement(by);     } 

It has worked reliably previously, but it is no longer working correctly. The problem is that the timeout is no longer being applied. It will keep looking indefinitely at least until the call to the web driver times out. This is a C# test program, and the driver is the chrome driver. It is fairly typically called using find by XPath but We use other find types as well. For example

var element = webDriver.FindElement(By.XPath(@"//h1[@class='m-t30'][contains(.,'My Profile')]"), 15); 

Any Idea why this is now failing>

Wait For Task But Forget It After Certain Time

Is there a way to wait for a task to end but move on after a certain period of time but let the task itself continue on? I would like a response back from a task within 5 seconds and don’t want to wait longer than that — however, if longer than 5 seconds have passed, I just want to move on and not actually cancel the task (ruling out cancellation tokens).

I’m using .NET Core / C#.

private async Task<string> MakeAuthRequest(Request request) {     try     {         var response = await SometimesLongMethod(request); // something needs to be done here, just not sure what         return response.Message;     }     catch(Exception e)     {         logger.Error(e, "Error occurred");         return string.Empty;     } } 

AppleScript: Wait for Firefox Page to load

https://apple.stackexchange.com/a/320105/319746

I was trying to find a Firefox equivalent to the script in the link above under the line “Safari’s Reload button”, which monitors particular properties of Safari’s Reload button. Therefore, I tried to write my own script for Firefox:

tell application "Firefox"     activate end tell  tell ¬     application "System Events" to tell ¬     process "Firefox" to tell ¬     window 1 to tell ¬     toolbar 2 to tell ¬     groups to tell ¬     UI element 1 to ¬     set reload_button to a reference to ¬         (first button whose name is "Reload current page")  using terms from application "System Events"     repeat until the accessibility description ¬         of the reload_button ¬         contains "Reload current page"     end repeat end using terms from  log "Finished loading" 

However, my script fails at “tell window 1”. I guess many parts of the script do not work for Firefox. How should I modify the script?

How to wait ‘return’ until ‘dispatch’ finish

[React JS]How to wait ‘return’ until ‘dispatch’ finish in action creator? I don’t know how handle this ;(

i made some code. this is a part of action creator. But it return before dispatch finish. i want to dispatch finish before ‘return’. help me please

export const Hello = param=> dispatch => {   return postApi('/hello', param)     .then(async res => {       await dispatch(goHello(res));        return true; }) 

Wait for calculations within loop to finish before return

I have two components, charValueMatcher and main. The charValueMatcher module accepts a string which it loops through and formats the string. When it’s done, the formatted string is returned. main is simply using this module.

charValueMatcher.js

module.exports = (string) => {   let formatted = [];   let i = 0;   while(i < string.length) {     if (string[i] === 'b') {       formatted.push({'b': 123});     } else {       formatted.push({[string[i]: 456}});     }     i ++;   }   return formatted; } 

main.js

const charValueMatcher = require('./charValueMatcher');  console.log(charValueMatcher('ManyLettersandbitsAndThings')); 

My issue here is that althought it works, in other words charValueMatcher doesn’t return an empty array, but the array of objects produced by the loop, it doesn’t feel very asyncronous to block the return statement with a while loop. How could I improve my code to take advantage of Node’s asyncronous nature?

Wait free triple buffer primitive

I’m trying to write a triple buffer that’s wait free for a update + render loop after being bitten by lock starvation one too many times (on a different project, using a library).

For reference, a triple buffer is effectively a single producer, single consumer channel, that allows for the producer to update the buffer while the consumer can always get the most recently updated buffer. Since the renderer only needs the most recent state to extrapolate a (soon to be) future state and the simulation could update many times in between, this fits. Since simulation data tends to update EVERYTHING as well as being kind of arbitrary, I wanted the write and read to be entirely unrestricted in what could be done to the buffers. Since I had to deal with starving rendering threads in the last assignment, I decided to make it lock free, then stumbled on what I think is wait free as well (it’s effectively a single fetch_nand statement).

Here’s the code (same as on GitHub):

use std::{     cell::UnsafeCell,     fmt::Debug,     sync::{         atomic::{AtomicBool, AtomicUsize},         Arc,     }, };  use cb::utils::CachePadded;  #[allow(unused_imports)] use log::{debug, error, info, trace, warn};  pub fn buffer<T: Clone>(src: T) -> (ReadingView<T>, EditingView<T>) {     TripleBuffer::alloc(src) }  #[derive(Debug)] struct TripleBufferIndices {     snatched_read: CachePadded<usize>,     // unique     packed_vals: CachePadded<AtomicUsize>, // shared     stale: CachePadded<AtomicBool>,        // shared     edit_rw: CachePadded<(usize, usize)>,  // unique } impl TripleBufferIndices {     #[inline]     fn pack(v0: usize, v1: usize) -> usize {         (0b0 << 4) + (v0 << 2) + ((!v1) & 0b11)     }     #[inline]     fn unpack(packed: usize) -> (usize, usize) {         let should_negate = ((packed >> 4) & 0b1) != 0;         let most_recent = (if should_negate { !packed } else { packed } >> 2) & 0b11;         let next_write = !packed & 0b11;         (most_recent, next_write)     }     fn snatch(&mut self) {         let mask = (0b1 << 4)             + (0b11 << 2)             + match *self.snatched_read {                 0 => 0b00,                 1 => 0b01,                 2 => 0b10,                 _ => panic!("We done goofed!"),             };         let old_snatched = self.snatched_read;         if !self.stale.swap(true, std::sync::atomic::Ordering::Acquire) {             *self.snatched_read = Self::unpack(                 self.packed_vals                     .fetch_nand(mask, std::sync::atomic::Ordering::AcqRel),             )             .0;             trace!(                 "Snatching indices {:?} and returning indices {:?}.",                 old_snatched,                 self.snatched_read             );         }     }     fn advance(&mut self) {         let next_write = Self::unpack(self.packed_vals.swap(             Self::pack(self.edit_rw.1, self.edit_rw.1),             std::sync::atomic::Ordering::AcqRel,         ))         .1;         self.stale.swap(false, std::sync::atomic::Ordering::Release);         trace!(             "Advancing indices from {:?} to {:?}.",             self.edit_rw.1,             next_write         );         self.edit_rw.0 = self.edit_rw.1;         self.edit_rw.1 = next_write;     } } impl Default for TripleBufferIndices {     fn default() -> Self {         Self {             snatched_read: CachePadded::new(0),             packed_vals: CachePadded::new(AtomicUsize::new(Self::pack(0, 2))),             stale: CachePadded::new(AtomicBool::new(true)),             edit_rw: CachePadded::new((1, 2)),         }     } }  struct TripleBuffer<T: Clone> {     ii: UnsafeCell<TripleBufferIndices>,     backing_mem: *const [UnsafeCell<CachePadded<T>>; 3],     tt: [*mut T; 3], } impl<T: Clone> TripleBuffer<T> {     pub fn alloc(src: T) -> (ReadingView<T>, EditingView<T>) {         let backing_mem = Box::into_raw(Box::new([             UnsafeCell::new(CachePadded::new(src.clone())),             UnsafeCell::new(CachePadded::new(src.clone())),             UnsafeCell::new(CachePadded::new(src)),         ]));         let mut tt: [*mut T; 3] = unsafe { std::mem::uninitialized() };         unsafe {             for i in 0..3 {                 tt[i] = &mut **(*backing_mem)[i].get();             }         }         let arc = Arc::new(Self {             ii: UnsafeCell::new(TripleBufferIndices::default()),             backing_mem,             tt,         });         (ReadingView(arc.clone()), EditingView(arc))     }     fn snatch(&self) {         let ii = self.ii.get();         unsafe { (*ii).snatch() };     }     fn advance(&self) {         let ii = self.ii.get();         unsafe { (*ii).advance() };     }     fn rr(&self) -> *const T {         let ii = self.ii.get();         self.tt[unsafe { *(*ii).snatched_read }]     }     fn er(&self) -> *const T {         let ii = self.ii.get();         self.tt[unsafe { (*ii).edit_rw.0 }]     }     fn ew(&self) -> *mut T {         let ii = self.ii.get();         self.tt[unsafe { (*ii).edit_rw.1 }]     } } impl<T: Clone> Drop for TripleBuffer<T> {     fn drop(&mut self) {         unsafe {             Box::from_raw(self.backing_mem as *mut [CachePadded<T>; 3]);         };     } }  pub struct RWPair<R, W> {     r: R,     w: W, }  pub enum Reading<T: Clone> {     ReadingView(ReadingView<T>),     Reader(Reader<T>), } pub struct ReadingView<T: Clone>(Arc<TripleBuffer<T>>); impl<T: Clone> ReadingView<T> {     pub fn read(self) -> Reader<T> {         Reader::from_view(self)     } } unsafe impl<T: Clone> Send for ReadingView<T> {} pub struct Reader<T: Clone> {     origin: ReadingView<T>,     locker: *const T, } impl<T: Clone> Reader<T> {     pub fn from_view(rv: ReadingView<T>) -> Reader<T> {         rv.0.snatch();         Self {             locker: rv.0.rr(),             origin: rv,         }     }     pub fn r<'a>(&'a self) -> &'a T {         unsafe { &*self.locker }     }     pub fn release(self) -> ReadingView<T> {         self.origin     } }  pub enum Editing<T: Clone> {     EditingView(EditingView<T>),     Editor(Editor<T>), } pub struct EditingView<T: Clone>(Arc<TripleBuffer<T>>); impl<T: Clone> EditingView<T> {     pub fn edit(self) -> Editor<T> {         Editor::from_view(self)     } } unsafe impl<T: Clone> Send for EditingView<T> {} pub struct Editor<T: Clone> {     origin: EditingView<T>,     rw_lock: RWPair<*const T, *mut T>, } impl<T: Clone> Editor<T> {     fn from_view(ev: EditingView<T>) -> Editor<T> {         Editor {             rw_lock: RWPair {                 r: ev.0.er(),                 w: ev.0.ew(),             },             origin: ev,         }     }     pub fn r<'a>(&'a self) -> &'a T {         unsafe { &*self.rw_lock.r }     }     pub fn w<'a>(&'a self) -> &'a mut T {         unsafe { &mut *self.rw_lock.w }     }     pub fn release(self) -> EditingView<T> {         self.origin.0.advance();         self.origin     } } 

And you can run it like this:

fn sort_of_a_test() {     let (rv, ev) = tb::buffer([0u8; 1_000]);     let e_th = std::thread::spawn(move || {         let mut ev = Some(ev);         let mut e = None;         for _ in 0..255 {             e.replace(ev.take().unwrap().edit());             // do some editing             let e_int = e.as_ref().unwrap();             for (rv, ev) in e_int.r().iter().zip(e_int.w().iter_mut()) {                 *ev = *rv + 1;             }             ev.replace(e.take().unwrap().release());         }     });     let r_th = std::thread::spawn(move || {         let mut rv = Some(rv);         let mut r = None;         let mut scratch = 0;         loop {             r.replace(rv.take().unwrap().read());             // do some reading             for v in r.as_ref().unwrap().r().iter() {                 scratch = *v;             }             rv.replace(r.take().unwrap().release());             if scratch == 255 {                 break;             }         }     });     e_th.join().expect("Failed to join editing thread.");     r_th.join().expect("Failed to join reading thread."); } 

EDIT: As a side note, I would like to avoid the Option swap there, if possible.

EDIT 2: Forgot to mention, cb is the crossbeam crate.